package com.xuzao.developer.enums;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.List;
import java.util.Map;

/**
 * @author xuzao
 * @description
 * @date 2019-08-22 15:29
 */
public enum WorkTypeEnum {
    JAVAER(0,"java开发"),
    TESTER(1,"测试人员"),
    WEBER(2,"前端开发"),
    PRODUCT(3,"产品经理"),
    PM(4,"项目经理");
    @Getter
    private int code;
    @Getter
    private String desc;

     WorkTypeEnum(int code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static WorkTypeEnum valueOf(Integer code){
         if (null == code){
             return null;
         }
        for (WorkTypeEnum value : WorkTypeEnum.values()) {
            if(value.getCode()== code){
                return value;
            }
        }
        return null;
    }

    public static List<Map<Object,Object>> getMap(Integer code){
        List<Map<Object,Object>> list = Lists.newArrayList();
        for (WorkTypeEnum value : WorkTypeEnum.values()) {
            Map<Object,Object> map = Maps.newHashMap();
            map.put("id",value.getCode());
            map.put("name",value.getDesc());
            map.put("selected","");
            if (code!=null && code == value.code){
                map.put("selected","selected");
            }
            list.add(map);
        }
        return list;
    }
}
